/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.unesp.ia.gridsolver.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Pardal
 */
@Entity
@Table(name = "slotmateria", catalog = "cursos", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Slotmateria.findAll", query = "SELECT s FROM Slotmateria s"),
    @NamedQuery(name = "Slotmateria.findByMateria", query = "SELECT s FROM Slotmateria s WHERE s.slotmateriaPK.materia = :materia"),
    @NamedQuery(name = "Slotmateria.findBySlot", query = "SELECT s FROM Slotmateria s WHERE s.slotmateriaPK.slot = :slot"),
    @NamedQuery(name = "Slotmateria.findByHorario", query = "SELECT s FROM Slotmateria s WHERE s.horario = :horario")})
public class Slotmateria implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SlotmateriaPK slotmateriaPK;
    @Column(name = "horario")
    private Integer horario;
    @JoinColumn(name = "Materia", referencedColumnName = "idMateria", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Materia materia1;

    public Slotmateria() {
    }

    public Slotmateria(SlotmateriaPK slotmateriaPK) {
        this.slotmateriaPK = slotmateriaPK;
    }

    public Slotmateria(int materia, int slot) {
        this.slotmateriaPK = new SlotmateriaPK(materia, slot);
    }

    public SlotmateriaPK getSlotmateriaPK() {
        return slotmateriaPK;
    }

    public void setSlotmateriaPK(SlotmateriaPK slotmateriaPK) {
        this.slotmateriaPK = slotmateriaPK;
    }

    public Integer getHorario() {
        return horario;
    }

    public void setHorario(Integer horario) {
        this.horario = horario;
    }

    public Materia getMateria1() {
        return materia1;
    }

    public void setMateria1(Materia materia1) {
        this.materia1 = materia1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (slotmateriaPK != null ? slotmateriaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Slotmateria)) {
            return false;
        }
        Slotmateria other = (Slotmateria) object;
        if ((this.slotmateriaPK == null && other.slotmateriaPK != null) || (this.slotmateriaPK != null && !this.slotmateriaPK.equals(other.slotmateriaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.unesp.ia.gridsolver.entity.Slotmateria[ slotmateriaPK=" + slotmateriaPK + " ]";
    }
    
}
